<?php
/**
 *  +----------------------------------------------------------------------
 *  | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
 *  +----------------------------------------------------------------------
 *  | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
 *  +----------------------------------------------------------------------
 *  | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
 *  +----------------------------------------------------------------------
 *  | Author: CRMEB Team <admin@crmeb.com>
 *  +----------------------------------------------------------------------
 */

/**
 * poststypes
 * @author crud自动生成代码
 * @date 2025/09/10 09:25:15
 */

namespace app\model\crud;


use crmeb\basic\BaseModel;

/**
 * Class PostsTypes
 * @date 2025/09/10
 * @package app\model\crud
 */
class PostsTypes extends BaseModel
{

    /**
     * 表名
     * @var string
     */
    protected $name = 'posts_types';

    /**
     * 主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 类型获取器
     * @date 2025-09-10
     * @param string $value
     * @return string
     */
    public function getTypeLabelAttr($value)
    {
        $attr = '';
        switch ((int)$value){
            case 0:
                $attr = '普通';
                break;
            case 1:
                $attr = '二手';
                break;
            case 2:
                $attr = '投票';
                break;
        }
        return $attr;
    }

    /**
     * 轮播图获取器
     * @date 2025-09-10
     * @param string $value
     * @return string
     */
    public function getImagesLabelAttr($value)
    {
        $value = $value ? json_decode($value, true) : [];
        return $value;
    }

}
